namespace OracleInternal.BinXml
{
	internal class PrefixInfo
	{
		internal string Prefix;

		internal string Uri;

		internal ulong Nsid;

		internal short PrefixId;

		internal PrefixInfo()
		{
			Prefix = string.Empty;
			Uri = string.Empty;
			Nsid = 0uL;
			PrefixId = 0;
		}

		internal PrefixInfo(ObxmlDecodeContext decodeContext, short pfxid, string prefix, ulong nsid, string uri = null)
		{
			if (!string.IsNullOrEmpty(uri))
			{
				Uri = uri;
			}
			else if (nsid != 0L && decodeContext != null && decodeContext.TokenMap != null)
			{
				ObxmlToken token = null;
				Uri = decodeContext.TokenMap.GetNamespaceUri(decodeContext, nsid, out token);
			}
			else
			{
				Uri = string.Empty;
			}
			PrefixId = pfxid;
			Prefix = prefix;
			Nsid = nsid;
		}

		internal static PrefixInfo GetPrefixInfo(ObxmlDecodeState decodeState, ulong prefixId, PrefixInfo prefixInfo, bool refetchPrefixInfo = false)
		{
			if (prefixId != 0 && (refetchPrefixInfo || prefixInfo == null))
			{
				prefixInfo = decodeState.GetPrefixInfo(prefixId);
			}
			return prefixInfo;
		}

		protected object Clone()
		{
			return new PrefixInfo(null, PrefixId, Prefix, Nsid, Uri)
			{
				Uri = Uri
			};
		}
	}
}
